package com.va.yahooweather.entity;

import com.va.yahooweather.commons.ConditionUtil;
import java.util.*;

public class YReport {
    private Date lastbuildDate = null;
    private YLocation location = null;
    private YUnit units = null;
    private YWind wind = null;
    private YImage image = null;
    private YCondition condition = null;
    private List<YForeCast> forecast = null;

    public YReport() { }

//    getters and setters
    public Date getLastbuildDate() {
        return lastbuildDate;
    }

    public void setLastbuildDate(Date lastbuildDate) {
        this.lastbuildDate = lastbuildDate;
    }

    public YLocation getLocation() {
        return location;
    }

    public void setLocation(YLocation location) {
        this.location = location;
    }

    public YUnit getUnits() {
        return units;
    }

    public void setUnits(YUnit units) {
        this.units = units;
    }

    public YWind getWind() {
        return wind;
    }

    public void setWind(YWind wind) {
        this.wind = wind;
    }

    public YImage getImage() {
        return image;
    }

    public void setImage(YImage image) {
        this.image = image;
    }

    public YCondition getCondition() {
        return condition;
    }

    public void setCondition(YCondition condition) {
        this.condition = condition;
    }

    public List<YForeCast> getForecast() {
        return forecast;
    }

    public void setForecast(List<YForeCast> forecast) {
        this.forecast = forecast;
    }

    @Override
    public String toString() {StringBuilder sb = new StringBuilder();
        sb.append(getLocation().toString())
            .append(" at ").append(getLastbuildDate().toString())
            .append("\n")
            .append("Current Weather: \n")
            .append(ConditionUtil.INSTANCE.getDescription(getCondition().getCode()))
            .append(", ")
            .append(getCondition().getTemp()).append(getUnits().getTemperature())
            .append("\n")
            .append("Wind: ")
            .append(getWind().getChill()).append(getUnits().getTemperature())
            .append(", ").append(getWind().getSpeed()).append(getUnits().getSpeed())
            .append("\n").append("Forecast: \n")
            ;
        
        for (Iterator<YForeCast> it = getForecast().iterator(); it.hasNext();) {
            YForeCast cast = it.next();
            sb.append(cast.getDay()).append(" - ")
                .append(ConditionUtil.INSTANCE.getDescription(cast.getCode()))
                .append(". High: ").append(cast.getHigh())
                .append(" Low: ").append(cast.getLow())
                .append("\n");
            
        }
        
        return sb.toString();
    }
    
}
